#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QPixmap>
#include <QPainter>

#include "ui_mainwindow.h"

#include "src\datamaker.h"
#include "src\procthread.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow {
Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);

    ~MainWindow();

    /**
     * 尝试走某一点
     * @param pixmap 对应QPixmap对象
     * @param painter 对应QPainter对象
     * @param row 行号
     * @param col 列号
     * @param color 颜色
     */
    void drawProcByRC(QLabel* label, QPixmap *pixmap, QPainter *painter, int row, int col, const QColor &color);

    /**
     * 尝试走某一点
     * @param pixmap 对应QPixmap对象
     * @param painter 对应QPainter对象
     * @param px x坐标
     * @param py y坐标
     * @param color 颜色
     */
    void drawProcByP(QLabel* label,QPixmap *pixmap, QPainter *painter, int px, int py, const QColor &color);

private:
    Ui::MainWindow *ui;

    bool isSpawnDataSuccessful = false; // 生成数据是否成功 不成功将不能运行解决迷宫问题的方法

    QPixmap *pixmapAStar;
    QPainter *painterAStar;

    QPixmap *pixmapDfs;
    QPainter *painterDfs;

    QPixmap *pixmapBfs;
    QPainter *painterBfs;

    QPixmap *pixmapDijkstra;
    QPainter *painterDijkstra;

    const int default_squareSize = 16;
    const int default_interval = 6;

    int squareSize;
    QSize squareQSize;

    int interval; // 图形化每个格子的间隙

    int m_n = 9; // 行数
    int m_m = 9; // 列数


signals:
    void spawnData(int n, int m, bool isEdge);
    void sendSize(int squareSize, int interval);
};

#endif // MAINWINDOW_H
